<template>
  <div class="header">
    <div class="left-section">
      <!-- <div class="avatar">
        <img :src="anchorData?.headImageUrl" alt="Player" class="player-image" />
      </div> -->
      <div>
        <div class="match-info">
          <!-- <span class="match-type">{{ data?.liveTitle }}</span> -->
        </div>
        <div class="additional-info">
          <!-- <span class="live-icon">{{ anchorData?.nickname }}</span> -->
          <!-- <span class="room-id">房间号 {{ anchorData?.roomRecordId }}</span> -->
          <!-- <span class="viewers"
            ><img src="@/assets/icons/live-detail/fire.webp" class="icon" />{{
              anchorData?.hotCount
            }}</span
          > -->
          <!-- <span class="host-id">主播ID {{ anchorData?.stb }}</span> -->
        </div>
      </div>
    </div>
    <div class="right-section">
      <!-- <div> -->
      <!-- <button class="followed">已关注</button> -->
      <!-- <button class="follow">+ 关注</button> -->
      <!-- </div> -->

      <div class="actions">
        <!-- <div class="report">
          <img src="@/assets/icons/live-detail/live-detail-report.webp" />举报/投诉
        </div> -->
        <!-- <div class="report">
          <img src="@/assets/icons/live-detail/live-detail-share.webp" />分享
        </div>
        <div class="report">
          <img src="@/assets/icons/live-detail/live-detail-download.webp" />手机看
        </div> -->
        <div class="player-tabs">
          <div
            @click="() => activeTabHandle(index)"
            :class="{ active: tabIndex === index }"
            class="player-tab"
            v-for="(item, index) in list"
            :key="index"
          >
            <img :src="index === tabIndex ? item.active : item.icon" />
            <span>{{ item.text }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { defineProps, watch, ref, reactive, defineEmits } from 'vue'
import dayjs from 'dayjs'
const myProps = defineProps(['renderContent'])
const myEmits = defineEmits(['activeTabHandle'])
const tabIndex = ref(0)
// console.log(myProps.match)
// let data = reactive({})
// let anchorData = reactive({})
const formatTime = (num) => {
  return dayjs(num).format('YYYY-MM-DD HH:mm:ss')
}

const list = ref([
  {
    icon: new URL('@/assets/icons/score/animation-default.webp', import.meta.url).href,
    active: new URL('@/assets/icons/score/animation-active.webp', import.meta.url).href,
    text: '动画直播'
  },
  {
    icon: new URL('@/assets/icons/score/video-default.webp', import.meta.url).href,
    active: new URL('@/assets/icons/score/video-active.webp', import.meta.url).href,
    text: '视频直播'
  }
])

const activeTabHandle = (index) => {
  tabIndex.value = index
  myEmits('activeTabHandle', index)
}

watch(
  () => myProps.renderContent,
  (newVal) => {
    // console.log(newVal, 'newVal')
    if (newVal.hasVideo) {
      activeTabHandle(1)
    }
  }
)
</script>
<style lang="scss" scoped>
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  //   background-color: #f4f7fa;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: Arial, sans-serif;

  .left-section {
    display: flex;
    align-items: center;

    .player-image {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      margin-right: 10px;
    }

    .match-info {
      display: flex;
      flex-direction: column;
      margin-right: 20px;

      .match-type {
        font-weight: 500;
        font-size: 20px;
        color: #525a79;
      }

      .teams {
        font-size: 18px;
        font-weight: bold;
        color: #3c3b54;
      }
    }

    .additional-info {
      display: flex;
      //   flex-direction: column;
      align-items: center;
      font-weight: 400;
      font-size: 12px;
      color: #afb8cb;

      .live-icon,
      .room-id,
      .viewers,
      .host-id {
        margin-top: 5px;
        margin-right: 20px;
        display: flex;
        align-items: center;
        .icon {
          width: 14px;
          margin-right: 5px;
        }
      }
    }
  }

  .right-section {
    display: flex;
    // align-items: center;
    flex-direction: column;
    align-items: flex-end;
    // justify-content: flex-end;
    font-weight: 400;
    font-size: 12px;
    color: #ffffff;
    .followed {
      background-color: #fff;
      color: #999;
      border: 1px solid #afb8cb;
      border-radius: 20px;
      padding: 5px 15px;
      margin-right: 10px;
      cursor: pointer;
    }

    .follow {
      background-color: #16b13a;
      color: white;
      border: none;
      border-radius: 20px;
      padding: 5px 15px;
      cursor: pointer;
    }

    .actions {
      display: flex;
      align-items: center;
      margin-left: 20px;
      color: #999;
      padding-top: 5px;

      .player-tabs {
        display: flex;
        background-color: #000;
        border-radius: 10px;
        overflow: hidden;
        .player-tab {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 100px;
          height: 30px;
          cursor: pointer;
          &.active {
            background-color: #fff;
            color: #000;
            span {
              color: rgba(22, 177, 58, 1);
            }
          }

          img {
            width: 20px;
            margin: 0 10px;
            margin-left: 10px;
            margin-right: 2px;
          }
        }
      }
      .report {
        display: flex;
        align-items: center;
        cursor: pointer;
        img {
          width: 10px;
          margin: 0 10px;
          margin-left: 10px;
          margin-right: 2px;
        }
      }
      span {
        margin-right: 10px;
        cursor: pointer;
      }
    }
  }
}
</style>
